<style lang="less" scoped>
.pdflist{
    .pdflist_data{
      background: white;
      padding-left: 0.5vw;
      padding-right: 0.5vw;
      width: 61vw;
      margin-left: 18.5vw;
      min-height: 35vw;
      .title{
        font-size: 1.1vw;
      }
      .pdfitemimg{
        background-image: url(../../../images/xinghao.png);
        background-size:100% 100%;
        width: 1.5vw;
        height: 1.5vw;
        margin-left: 2vw;
      }
      .pdfitemtitle{
        font-size: 0.9vw;
        line-height: 1.5vw;
        margin-left: 2vw;;
      }
      .pdfitem_data{
        cursor:pointer;
        margin-top: 1vw;
        margin-left: 2vw;
      }
      .pdfitemtitle:hover{
        color: #fa4400;
      }
      .pdflist_b{
        width: 61vw;
        min-height: 39vw;
      }
  }
}


</style>
<template>
  <div class="pdflist">
    <MainUser></MainUser>
    <!-- <div v-if="size>20" style="height:3.2vw"></div> -->
    <!-- <affix v-if="size>20" style="margin-top:-3.2vw">
      <MainTitle  ref="maintitle"></MainTitle>
    </affix> -->
    <MainTitle ></MainTitle>
    
    <div class="pdflist_data" v-loading="loading">
      <div style="height:0.5vw;"></div>
        <div class="title">{{title}}</div>
        <div class="pdflist_b">
          <el-row :gutter="20">
            
            <div  v-if="type != 2" v-for="item in test_reportslist" class="pdfitem_data" @click="dakaipdf(item.id)">
                <!-- <div class="pdfitemtitle" v-if="item.titleheader && type == 1"><b style="color:#d25513">{{item.titleheader}}</b>{{item.titledata}}</div> -->
                <div v-if="type == 3 || !item.titleheader" v-html="item.title" class="pdfitemtitle"></div>
            </div>
          </el-row>
        </div>
        
      <div style="height:1vw"></div>
        <el-pagination
          background
          style="text-align: right"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          layout="prev, pager, next,sizes"
          :current-page="pagintion.page"
          :page-sizes="pagesizes"
          :page-size="pagintion.page_size"
          :total="pagintion.total">
        </el-pagination>
        <div style="height:1vw"></div>
    </div>
    
  </div>
</template>
<script>
import { test_reports } from '@/request/api';
import MainTitle from '../main_title'
import MainUser from '../main_user'
export default {
    data() {
        return {
            test_reportslist:[
            ],
            loading:false,
            size:0,
            type:0,
            title:"",
            pagintion: {
              total: 0,
              page_size:15,
              page: 1,
            },
            pagesizes: [15],
        }
    },
    mounted() {
        this.type = this.$route.query.type;
        if(this.type == 1){
          this.title="标准制定";
        }
        if(this.type == 3){
          this.title="自学课件";
        }
        this.gettest_reportslist();
    },
    methods: {
      //翻页
      handleCurrentChange(val) {
        this.pagintion.page = val;
        this.gettest_reportslist();
      },
      //修改条数
      handleSizeChange(val){
        this.pagintion.page_size = val;
        this.gettest_reportslist();
      },
      //获取小概念pdf列表
      gettest_reportslist(){
          var param = {};
          param.page = this.pagintion.page;
          param.size = this.pagintion.page_size;
          param.type = this.type;
          this.loading = true;
          test_reports(param).then(res => {
            this.loading = false;
            if(res.ok){
              this.pagintion.total = res.data.total;
              this.test_reportslist = res.data.data;
                // this.size = this.test_reportslist.length;
                // if(this.type == 1){
                //   for(var i = 0;i<this.test_reportslist.length;i++){
                //     var titleheader = this.test_reportslist[i].title.slice(0, 6);
                //     if(titleheader.indexOf("企业标准") != -1){
                //       this.test_reportslist[i].titleheader = titleheader;
                //       this.test_reportslist[i].titledata = this.test_reportslist[i].title.slice(6,this.test_reportslist[i].title.length);
                //     }
                //   }
                // }
            }
          })
      },
      dakaipdf(id){
        console.log("ssssssssss"+id);
        let routeUrl = this.$router.resolve({
          path: 'jlb_xgnpdf',
          query: {'id': id}
        });
        window.open(routeUrl.href, '_blank');
      }
    },
    components: {
        MainTitle,
        MainUser
    },

}
</script>
